<style>
    .dakq-role-title
    {
        font-size: 16px;
        font-weight: bolder;
    }
</style>

{php}if(!isset($role))$role["authority"]=array();{/php}
{php}generate_admin_authority($role);{/php}

<script>
    $(function () {
        $("[data-toggle='role-title']").on("click", function () {
            //获取类型名
            var type = $(this).attr("data-type");

            //判断是否被选中
            if ($(this).prop("checked"))
            {
                $("[data-type='" + type + "']").prop("checked", true);
            }
            else
            {
                $("[data-type='" + type + "']").prop("checked", false);
            }
        });

        $("[data-toggle='role-item']").on("click", function () {
            //获取类型名
            var type = $(this).attr("data-type");

            //判断是否被选中
            if ($(this).prop("checked"))
            {
                $("[data-type='" + type + "'][data-toggle='role-title']").prop("checked", true);
                //获取所有的此类按钮数量
                //var total = $("[data-type='" + type + "'][data-toggle='role-item']").length;
                //var checked = $(":checked[data-type='" + type + "'][data-toggle='role-item']").length;
                //
                //if (checked == total)
                //{
                //$("[data-type='" + type + "'][data-toggle='role-title']").prop("checked", true);
                //}
            }
            else
            {
                var checked = $(":checked[data-type='" + type + "'][data-toggle='role-item']").length;
                if(checked==0)
                {
                    $("[data-type='" + type + "'][data-toggle='role-title']").prop("checked", false);
                }
            }

        })
    })
</script>